package com.kdtech.analyse.video;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import com.kdtech.crawler.CrawlHTML;
import com.kdtech.crawler.at.UrlArgumentTop;
import com.kdtech.entity.crawler.UrlMeta;
import com.kdtech.entity.data.NewsMeta;
import com.kdtech.analyse.AnalyseNews;
import com.kdtech.utils.DateUtils;
import com.kdtech.utils.NumberUtils;
import com.kdtech.utils.RegexUtils;
import com.kdtech.utils.StringUtils;

/**
 * <电视台 - 丹阳电视台> 解析类
 *
 * @author KK
 *
 */
public class DanyangAnalyse implements AnalyseNews {



	
	public boolean isDetailPage(String url) {


		String[] regex = {
				"http://v.danyang.com/index.php\\?a=show&c=index&catid=[0-9]+&id=[0-9]+&m=content",
				};

		return RegexUtils.matchAny(url,regex);
	}

	
	public NewsMeta parserHtml(UrlMeta urlMeta) {
		if (urlMeta.getHtml() == null) {
		}
		String htmltxt = urlMeta.getHtml();
		String url = urlMeta.getUrl();

		String title = null;
		String content = null;
		Long date = null;
		String dateStr = null;
		String commnetNum = null;
		String clickNum = null;
		Document doc = Jsoup.parse(htmltxt);

		title = StringUtils.substringBefore(doc.select("title").text()," - ");
		date = DateUtils.matchDate(doc.select("h1").text());

			NewsMeta news = new NewsMeta();
			news.setUrl(url);
			news.setType(2);
			news.setTitle(StringUtils.trimSpace(title));
			news.setCommentNum(NumberUtils.parseInt(commnetNum));
			news.setClickNum(NumberUtils.parseInt(clickNum));
			news.setDate(date);
			return news;
	}


	

	
	public NewsMeta Update(NewsMeta meta) {
		return null;
	}
	
}
